package com.renwei.yunlong.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.renwei.yunlong.R;
import com.renwei.yunlong.base.BaseActivity;
import com.zyf.fwms.commonlibrary.utils.AutoUtils;
import com.zyf.fwms.commonlibrary.utils.CommonUtils;
import com.zyf.fwms.commonlibrary.utils.StatusBarUtil;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 确认工单--页面
 * <p>
 * Created by Administrator on 2017/8/29.
 */

public class ConfirmWorkActivity extends BaseActivity implements View.OnClickListener {

    @Bind(R.id.iv_back)
    ImageView ivBack;
    @Bind(R.id.tv_title)
    TextView tvTitle;
    @Bind(R.id.btn_solved)
    Button btnSolved;
    @Bind(R.id.btn_unsolved)
    Button btnUnsolved;
    @Bind(R.id.iv_one)
    ImageView ivOne;
    @Bind(R.id.iv_two)
    ImageView ivTwo;
    @Bind(R.id.iv_three)
    ImageView ivThree;
    @Bind(R.id.iv_four)
    ImageView ivFour;
    @Bind(R.id.iv_fives)
    ImageView ivFives;
    @Bind(R.id.tv_level)
    TextView tvLevel;//显示星级
    @Bind(R.id.btn_confirm)
    Button btnConfirm;
    @Bind(R.id.ll_solved)
    LinearLayout llSolved;//已解决列表
    @Bind(R.id.ll_unsolved)
    LinearLayout llUnsolved;//未解决列表
    @Bind(R.id.rl_level)
    RelativeLayout rlLevel;//星级

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_confirm_work);
        ButterKnife.bind(this);

        StatusBarUtil.setColor(this, CommonUtils.getColor(this, R.color.title_color), 0);

        //屏幕自适配
        AutoUtils.setSize(this, false, 720, 1280);
        AutoUtils.auto(this);

        initData();
    }

    private void initData() {
        ivBack.setVisibility(View.VISIBLE);
        tvTitle.setText("确认工单");
        ivBack.setOnClickListener(this);
        ivOne.setOnClickListener(this);
        ivTwo.setOnClickListener(this);
        ivThree.setOnClickListener(this);
        ivFour.setOnClickListener(this);
        ivFives.setOnClickListener(this);
        btnSolved.setOnClickListener(this);
        btnUnsolved.setOnClickListener(this);
        btnConfirm.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.btn_solved://确认解决
                btnSolved.setBackgroundResource(R.drawable.shape_deal_solved_dialog_pre);
                btnSolved.setTextColor(getResources().getColor(R.color.white));
                btnUnsolved.setBackgroundResource(R.drawable.shape_deal_unsolved_dialog_nor);
                btnUnsolved.setTextColor(getResources().getColor(R.color.text_black_color));

                rlLevel.setVisibility(View.VISIBLE);
                llSolved.setVisibility(View.VISIBLE);
                llUnsolved.setVisibility(View.GONE);

                break;
            case R.id.btn_unsolved://未完成
                btnSolved.setBackgroundResource(R.drawable.shape_deal_solved_dialog_nor);
                btnSolved.setTextColor(getResources().getColor(R.color.text_black_color));
                btnUnsolved.setBackgroundResource(R.drawable.shape_deal_unsolved_dialog_pre);
                btnUnsolved.setTextColor(getResources().getColor(R.color.white));

                rlLevel.setVisibility(View.GONE);
                llSolved.setVisibility(View.GONE);
                llUnsolved.setVisibility(View.VISIBLE);

                break;
            case R.id.iv_one:
                ivOne.setImageResource(R.mipmap.star_pre);

                ivTwo.setImageResource(R.mipmap.star_nor);
                ivThree.setImageResource(R.mipmap.star_nor);
                ivFour.setImageResource(R.mipmap.star_nor);
                ivFives.setImageResource(R.mipmap.star_nor);
                break;
            case R.id.iv_two:
                ivTwo.setImageResource(R.mipmap.star_pre);

                ivOne.setImageResource(R.mipmap.star_pre);
                ivThree.setImageResource(R.mipmap.star_nor);
                ivFour.setImageResource(R.mipmap.star_nor);
                ivFives.setImageResource(R.mipmap.star_nor);
                break;
            case R.id.iv_three:
                ivThree.setImageResource(R.mipmap.star_pre);

                ivOne.setImageResource(R.mipmap.star_pre);
                ivTwo.setImageResource(R.mipmap.star_pre);
                ivFour.setImageResource(R.mipmap.star_nor);
                ivFives.setImageResource(R.mipmap.star_nor);
                break;
            case R.id.iv_four:
                ivFour.setImageResource(R.mipmap.star_pre);

                ivOne.setImageResource(R.mipmap.star_pre);
                ivTwo.setImageResource(R.mipmap.star_pre);
                ivThree.setImageResource(R.mipmap.star_pre);
                ivFives.setImageResource(R.mipmap.star_nor);
                break;
            case R.id.iv_fives:
                ivFives.setImageResource(R.mipmap.star_pre);

                ivOne.setImageResource(R.mipmap.star_pre);
                ivTwo.setImageResource(R.mipmap.star_pre);
                ivThree.setImageResource(R.mipmap.star_pre);
                ivFour.setImageResource(R.mipmap.star_pre);
                break;
            case R.id.btn_confirm:
                break;
            default:
                break;
        }
    }
}
